import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { fileURLToPath } from 'url';

const __dirname = fileURLToPath(new URL('.', import.meta.url));

export default defineConfig({
  plugins: [vue()],
  build: {
    outDir: 'dist',
    lib: {
      entry: path.resolve(__dirname, 'src/index.ts'),
      name: 'StatusTable',
      fileName: (format) => `statustable.${format}.js`,
      formats: ['es', 'umd']
    },
    rollupOptions: {
      external: ['vue', 'ant-design-vue', 'echarts', 'vue-echarts'],
      output: {
        globals: {
          vue: 'Vue',
          'ant-design-vue': 'Antd',
          echarts: 'echarts',
          'vue-echarts': 'VueEcharts'
        }
      }
    }
  }
})
